﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Threading;
using System.Collections.ObjectModel;

namespace Bonobo.Irc.Client
{
    /// <summary>
    /// Extension
    /// </summary>
    public static class INotifyPropertyChangedExtensions
    {
        // zabaleni PropertyChangedEvenHandler do SendOrPostCallback delegata
        public static SendOrPostCallback OnPropertyChanged(this INotifyPropertyChanged self, PropertyChangedEventHandler handler, String propertyName)
        {
            return unused => handler(self, new PropertyChangedEventArgs(propertyName));
        }
    }

    /// <summary>
    /// Reprezentuje irc channel obsahuje osoby, atp.
    /// </summary>
    public class IrcChannel : INotifyPropertyChanged
    {
        private readonly IrcSession _session;
        private PropertyChangedEventHandler _onPropChanged;

        public ReadOnlyObservableCollection<IrcPerson> People
        {
            get
            {
                throw new System.NotImplementedException();
            }
        }

        public String Topic
        {
            get
            {
                throw new System.NotImplementedException();
            }
            set
            {
                // _session.SendCommand(IrcCommands.SetTopic(_name, value), OnTopicSet);
                // _session.Post(this.OnPropertyChanged(_onPropChanged, "Topic"), null);
            }
        }
    
        public void Join()
        {
            throw new System.NotImplementedException();
        }

        #region INotifyPropertyChanged Members

        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add { _onPropChanged += value; }
            remove { _onPropChanged -= value; }
        }

        #endregion
    }
}
